import { http, Method } from "@/utils/request.js";

/**
 * 获取订单列表
 * @param {*} params
 * @returns
 */
export function getOrderList(params) {
  return http.request({
    url: `/order/order`,
    method: Method.GET,
    params,
  });
}

/**
 * 获取订单详情
 * @param {*} params
 * @returns
 */
export function getOrderDetail(sn) {
  return http.request({
    url: `/order/order/${sn}`,
    method: Method.GET,
  });
}

/**
 * 查询物流
 * @param {*} params
 * @returns
 */
export function getTraces(sn) {
  return http.request({
    url: `/order/order/getTraces/${sn}`,
    method: Method.GET,
  });
}

/**
 * 修改收货地址
 * @param {*} params
 * @returns
 */
export function editOrderConsignee(sn, params) {
  return http.request({
    url: `/order/order/update/${sn}/consignee`,
    method: Method.POST,
    header: { "content-type": "application/x-www-form-urlencoded" },
    data: params,
  });
}

/**
 * 获取商家选中的物流公司
 * @param {*} params
 * @returns
 */
export function getLogisticsChecked(params) {
  return http.request({
    url: `/other/logistics/getChecked`,
    method: Method.GET,
    params,
  });
}

/**
 * 订单发货
 * @param {*} params
 * @returns
 */
export function orderDelivery(sn, params) {
  return http.request({
    url: `/order/order/${sn}/delivery`,
    method: Method.POST,
    header: { "content-type": "application/x-www-form-urlencoded" },
    data: params,
  });
}

/**
 * 调整订单金额
 * @param {*} params
 * @returns
 */
export function modifyOrderPrice(sn, params) {
  return http.request({
    url: `/order/order/update/${sn}/price`,
    method: Method.PUT,
    header: { "content-type": "application/x-www-form-urlencoded" },
    data: params,
  });
}

/**
 * 订单核验
 * @param {*} params
 * @returns
 */
export function orderTake(sn, params) {
  return http.request({
    url: `/order/order/take/${sn}/${params}`,
    method: Method.PUT,
    header: { "content-type": "application/x-www-form-urlencoded" },
  });
}

/**
 * 售后服务单
 * @param {*} params
 * @returns
 */
export function afterSaleOrderPage(params) {
  return http.request({
    url: `/order/afterSale/page`,
    method: Method.GET,
    params,
  });
}

/**
 * 售后服务单详情
 * @param {*} params
 * @returns
 */
export function afterSaleOrderDetail(params) {
  return http.request({
    url: `/order/afterSale/${params.sn}`,
    method: Method.GET,
    params,
  });
}

/**
 * 商家审核
 * @param {*} sn
 * @param {*} params
 * @returns
 */
export function afterSaleSellerReview(sn, params) {
  return http.request({
    url: `/order/afterSale/review/${sn}`,
    params,
    method: Method.PUT,
    header: { "content-type": "application/x-www-form-urlencoded" },
  });
}


/**
 * 售后单商家查询物流
 * @param {*} sn
 * @returns
 */
 export function getSellerDeliveryTraces(sn) {
  return http.request({
    url: `/order/afterSale/getSellerDeliveryTraces/${sn}`,
    method: Method.GET,
  });
}

/**
 * 售后单查询物流
 * @param {*} sn
 * @returns
 */
 export function getAfterSaleTraces(sn) {
  return http.request({
    url: `/order/afterSale/getDeliveryTraces/${sn}`,
    method: Method.GET,
  });
}

/**
 * 商家确认收货
 * @param {*} sn
 * @returns
 */
 export function afterSaleSellerConfirm(sn,params) {
  return http.request({
    url: `/order/afterSale/confirm/${sn}`,
    method: Method.PUT,
    params,
    header: { "content-type": "application/x-www-form-urlencoded" },
  });
}



/**
 * 获取投诉列表
 * @param {*} params
 * @returns
 */
 export function getComplainPage(params) {
  return http.request({
    url: `/order/complain`,
    method: Method.GET,
    params
  });
}


/**
 * 获取投诉详情
 * @param {*} id
 * @returns
 */
 export function getComplainDetail(id) {
  return http.request({
    url: `/order/complain/${id}`,
    method: Method.GET,
  });
}


/**
 * 添加交易投诉对话
 * @param {*} id
 * @returns
 */
 export function addOrderComplaint(params) {
  return http.request({
    url: `/order/complain/communication/`,
    method: Method.POST,
    params
  });
}



/**
 * 添加交易投诉对话
 */
 export function appeal(params) {
  return http.request({
    url: `/order/complain/appeal`,
    method: Method.PUT,
    params,
    header: { "content-type": "application/x-www-form-urlencoded" },
  });
}


/**
 * 获取商家结算单详细
 */
 export function getBillDetail(id) {
  return http.request({
    url: `/order/bill/get/${id}`,
    method: Method.GET,
  });
}


/**
 * 核对结算单
 */
 export function reconciliation(id,params) {
  return http.request({
    url: `/order/bill/check/${id}/`,
    method: Method.PUT,
    params,
    header: { "content-type": "application/x-www-form-urlencoded" },
  });
}

/**
 * 获取发票列表
 */
 export function getReceiptPage(params) {
  return http.request({
    url: `/trade/receipt`,
    method: Method.GET,
    params,
  });
}

/**
 * 换货维修发货
 * @param {*} params
 * @returns
 */
export function orderSendAsync(sn, params) {
  return http.request({
    url: `/order/afterSale/delivery/${sn}`,
    method: Method.POST,
    header: { "content-type": "application/x-www-form-urlencoded" },
    data: params,
  });
}

